var bodyPartData= new Array();
function initPage(baseInfoJson,operateInfoJson){
	var basePath = $("#basePath").val();
	$("select").each(function(){
		$(this).append("<option value=''>---请选择---</option>");
	});
	
	var bodyParts = baseInfoJson['bodyParts'];//身体部位
	for(var index in bodyParts){
		var bodyPart = bodyParts[index];
		var temBodyPart = new Object();
		temBodyPart[bodyPart.uniq_code] = bodyPart.label;
		bodyPartData.push(temBodyPart);
    	/*options+="<option value='"+incisionLevel.uniq_code+"'>"+incisionLevel.label+"</option>"*/
    } 
	
	var incisionLevels = baseInfoJson['incisionLevels'];//切口等级
	$("select[name$='.incisionLevelCode']").each(function(){
		var options = "";
		for(var index in incisionLevels){
			var incisionLevel = incisionLevels[index];
	    	options+="<option value='"+incisionLevel.uniq_code+"'>"+incisionLevel.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	var surgicalSiteInfections = baseInfoJson['surgicalSiteInfections'];//切口感染部位
	$("select[name$='.surgicalSiteInfectionCode']").each(function(){
		var options = "";
		for(var index in surgicalSiteInfections){
			var record = surgicalSiteInfections[index];
	    	options+="<option value='"+record.uniq_code+"'>"+record.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	var cicatrizeTypes = baseInfoJson['cicatrizeTypes'];//手术类型
	$("select[name$='.cicatrizeTypeCode']").each(function(){
		var options = "";
		for(var index in cicatrizeTypes){
			var cicatrizeType = cicatrizeTypes[index];
	    	options+="<option value='"+cicatrizeType.uniq_code+"'>"+cicatrizeType.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	var patientSources = baseInfoJson['patientSources'];//愈合类型
	$("select[name$='.patientSourceCode']").each(function(){
		var options = "";
		for(var index in patientSources){
			var patientSource = patientSources[index];
	    	options+="<option value='"+patientSource.uniq_code+"'>"+patientSource.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	var opsLevels = baseInfoJson['opsLevels'];//手术级别
	$("select[name$='.opsLevelCode']").each(function(){
		var options = "";
		for(var index in opsLevels){
			var opsLevel = opsLevels[index];
	    	options+="<option value='"+opsLevel.uniq_code+"'>"+opsLevel.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	var opsMarks = baseInfoJson['opsMarks'];//手术类别
	$("select[name$='.operatMarkCode']").each(function(){
		var options = "";
		for(var index in opsMarks){
			var opsMark = opsMarks[index];
	    	options+="<option value='"+opsMark.uniq_code+"'>"+opsMark.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	var opsRiskLevels = baseInfoJson['opsRiskLevels'];//手术风险分级
	$("select[name$='.operateRiskLevelCode']").each(function(){
		var options = "";
		for(var index in opsRiskLevels){
			var opsRiskLevel = opsRiskLevels[index];
	    	options+="<option value='"+opsRiskLevel.uniq_code+"'>"+opsRiskLevel.label+"</option>"
	    } 
       $(this).append(options);
	});

	var anaesthesiaLevels = baseInfoJson['anaesthesiaLevels'];//麻醉分级

	$("select[name$='.anaesthesiaLevelCode']").each(function(){
		var options = "";
		for(var index in anaesthesiaLevels){
			var anaesthesiaLevel = anaesthesiaLevels[index];
	    	options+="<option value='"+anaesthesiaLevel.uniq_code+"'>"+anaesthesiaLevel.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	
	var anaesthesiaWays = baseInfoJson['anaesthesiaWays'];//麻醉方式
	
	$("select[name$='.anaesthesiaTypeCode']").each(function(){
		var options = "";
		for(var index in anaesthesiaWays){
			var anaesthesiaWay = anaesthesiaWays[index];
	    	options+="<option value='"+anaesthesiaWay.uniq_code+"'>"+anaesthesiaWay.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	var anaesthesiaUnintendeds = baseInfoJson['anaesthesiaUnintendeds'];//麻醉非预期事件
	
	$("select[name$='.anaesthesiaUnintendedCode']").each(function(){
		var options = "";
		for(var index in anaesthesiaUnintendeds){
			var record = anaesthesiaUnintendeds[index];
	    	options+="<option value='"+record.uniq_code+"'>"+record.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	var opsedComplications = baseInfoJson['opsedComplications'];//术后并发症
	
	$("select[name$='.operatedComplicationCode']").each(function(){
		var options = "";
		for(var index in opsedComplications){
			var record = opsedComplications[index];
	    	options+="<option value='"+record.uniq_code+"'>"+record.label+"</option>"
	    } 
       $(this).append(options);
	});
	
	$("select[name$='.unPlanReOperateReasonCode']").each(function(){
		var options = "";
		
	    options+="<option value='1'>并发手术</option>";
	    options+="<option value='2'>医源性手术</option>";
	    options+="<option value='3'>非预期手术</option>";
	    options+="<option value='4'>其他原因</option>";
       $(this).append(options);
	});
	$("select[name$='.surgicalSiteCategoryCode']").each(function(){
		var options = "";
		options+="<option value='1'>浅层组织手术</option>";
		options+="<option value='2'>深部组织手术</option>";
		options+="<option value='3'>器官手术</option>";
		options+="<option value='4'>腔隙内手术</option>";
		$(this).append(options);
	});
	$("select[name$='.unPlanReOperateIntervalCode']").each(function(){
		var options = "";
		options+="<option value='1'>当天</option>";
		options+="<option value='2'>2-15天</option>";
		options+="<option value='3'>16-31天</option>";
		options+="<option value='4'>大于31天</option>";
		$(this).append(options);
	});
	/* 选项卡切换
    $.each($("#operate_record_ul li"),function(i,item) {
        $(item).on("click", function (){
            $(this).addClass("selected").siblings().removeClass("selected");
            $("#operation_record"+$(this).attr("data-index")).show().siblings().hide();
        });
    });*/
	 var validator = $("#operateInfoForm").validate({
			errorElement: "title",
			ignore: [],
			submitHandler:function(form){
				var url = $(form).attr("action");
				layer.load(1,{offset: '350px'});
				/*if(url){
					return true;
				}*/
				return true;
			},
			rules:{
							
			}
		});
	var operateRecords = operateInfoJson['operateRecords'];//手术记录集合
	for(var index in operateRecords){
		var operateRecord = operateRecords[index];
		
		addOperateRecordByRecord(operateRecord);
	}
	
    if($("#operate_record_ul li").length <1){
    	addOperateRecord();
    }else{
    	$("#operate_record_ul li").first().click();
    }
   
    
	
}

function copyOperateRecord(){
	var delete_option = $("#operate_record_ul li[class='selected']");
	var delete_index = delete_option.attr("data-index");
	var copyRecord = $("#operation_record"+delete_index);
	var add_content = addOperateRecord();
	
	add_content.find("input[name$='.operateStartDate']").val(copyRecord.find("input[name$='.operateStartDate']").val());
	add_content.find("input[name$='.operateEndDate']").val(copyRecord.find("input[name$='.operateEndDate']").val());
	add_content.find("input[name$='.anesthesiaStartTime']").val(copyRecord.find("input[name$='.anesthesiaStartTime']").val());
	add_content.find("input[name$='.anesthesiaEndTime']").val(copyRecord.find("input[name$='.anesthesiaEndTime']").val());
	add_content.find("span[class='operateOriginalShow']").html(copyRecord.find("span[class='operateOriginalShow']").html());
	add_content.find("input[name$='.operateOriginalDesc']").val(copyRecord.find("input[name$='.operateOriginalDesc']").val());
	add_content.find("input[name$='.operateOriginalCode']").val(copyRecord.find("input[name$='.operateOriginalCode']").val());
	/*var opsLevelCode = copyRecord.find("select[name$='.opsLevelCode']").val();
	var opsLevelName = copyRecord.find("input[name$='.opsLevelName']").val();
	if(opsLevelCode){
		
		var selectOption = add_content.find("select[name$='.opsLevelCode']").find("option[value='"+opsLevelCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.opsLevelCode']").append("<option selected='selected' value='"+opsLevelCode+"'>"+opsLevelName+"</option>");
		}
	}
	add_content.find("input[name$='.opsLevelName']").val(opsLevelName);
	
	var operatMarkCode = copyRecord.find("select[name$='.operatMarkCode']").val();
	var operatMarkName = copyRecord.find("input[name$='.operatMarkName']").val();
	if(operatMarkCode){
		
		var selectOption = add_content.find("select[name$='.operatMarkCode']").find("option[value='"+operatMarkCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.operatMarkCode']").append("<option selected='selected' value='"+operatMarkCode+"'>"+operatMarkName+"</option>");
		}
	}
	add_content.find("input[name$='.operatMarkName']").val(operatMarkName);*/
	
	var incisionLevelCode = copyRecord.find("select[name$='.incisionLevelCode']").val();
	var incisionLevelName = copyRecord.find("input[name$='.incisionLevelName']").val();
	if(incisionLevelCode){
		var selectOption = add_content.find("select[name$='.incisionLevelCode']").find("option[value='"+incisionLevelCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.incisionLevelCode']").append("<option selected='selected' value='"+incisionLevelCode+"'>"+incisionLevelName+"</option>");
		}
	}
	add_content.find("input[name$='.incisionLevelName']").val(incisionLevelName);
	
	var cicatrizeTypeCode = copyRecord.find("select[name$='.cicatrizeTypeCode']").val();
	var cicatrizeTypeName = copyRecord.find("input[name$='.cicatrizeTypeName']").val();
	if(incisionLevelCode){
		var selectOption = add_content.find("select[name$='.cicatrizeTypeCode']").find("option[value='"+cicatrizeTypeCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.cicatrizeTypeCode']").append("<option selected='selected' value='"+cicatrizeTypeCode+"'>"+cicatrizeTypeName+"</option>");
		}
	}
	add_content.find("input[name$='.cicatrizeTypeName']").val(cicatrizeTypeName);
	
	
	var anaesthesiaLevelCode = copyRecord.find("select[name$='.anaesthesiaLevelCode']").val();
	var anaesthesiaLevelName = copyRecord.find("input[name$='.anaesthesiaLevelName']").val();
	if(anaesthesiaLevelCode){
		var selectOption = add_content.find("select[name$='.anaesthesiaLevelCode']").find("option[value='"+anaesthesiaLevelCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.anaesthesiaLevelCode']").append("<option selected='selected' value='"+anaesthesiaLevelCode+"'>"+anaesthesiaLevelName+"</option>");
		}
	}
	add_content.find("input[name$='.anaesthesiaLevelName']").val(anaesthesiaLevelName);
	
	
	var anaesthesiaTypeCode = copyRecord.find("select[name$='.anaesthesiaTypeCode']").val();
	var anaesthesiaTypeName = copyRecord.find("input[name$='.anaesthesiaTypeName']").val();
	if(anaesthesiaTypeCode){
		var selectOption = add_content.find("select[name$='.anaesthesiaTypeCode']").find("option[value='"+anaesthesiaTypeCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.anaesthesiaTypeCode']").append("<option selected='selected' value='"+anaesthesiaTypeCode+"'>"+anaesthesiaTypeName+"</option>");
		}
	}
	add_content.find("input[name$='.anaesthesiaTypeName']").val(anaesthesiaTypeName);
	
	var anaesthesiaUnintendedCode = copyRecord.find("select[name$='.anaesthesiaUnintendedCode']").val();
	var anaesthesiaUnintendedName = copyRecord.find("input[name$='.anaesthesiaUnintendedName']").val();
	if(anaesthesiaUnintendedCode){
		var selectOption = add_content.find("select[name$='.anaesthesiaUnintendedCode']").find("option[value='"+anaesthesiaUnintendedCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.anaesthesiaUnintendedCode']").append("<option selected='selected' value='"+anaesthesiaUnintendedCode+"'>"+anaesthesiaUnintendedName+"</option>");
		}
	}
	add_content.find("input[name$='.anaesthesiaUnintendedName']").val(anaesthesiaUnintendedName);
	
	var operateBodyPartCodes = copyRecord.find("input[name$='.operateBodyPartCodes']").val();
	add_content.find("input[name$='.operateBodyPartCodes']").val(operateBodyPartCodes);
	
	var operateBodyPartNames = copyRecord.find("input[name$='.operateBodyPartNames']").val();
	add_content.find("input[name$='.operateBodyPartNames']").val(operateBodyPartNames);
	
	add_content.find("div[id^='operateBodyPart']").attr("data-id",operateBodyPartCodes).html(operateBodyPartNames);
	
	var patientSourceCode = copyRecord.find("select[name$='.patientSourceCode']").val();
	var patientSourceName = copyRecord.find("input[name$='.patientSourceName']").val();
	if(patientSourceCode){
		var selectOption = add_content.find("select[name$='.patientSourceCode']").find("option[value='"+patientSourceCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.patientSourceCode']").append("<option selected='selected' value='"+patientSourceCode+"'>"+patientSourceName+"</option>");
		}
	}
	add_content.find("input[name$='.patientSourceName']").val(patientSourceName);
	
	var operateRiskLevelCode = copyRecord.find("select[name$='.operateRiskLevelCode']").val();
	var operateRiskLevelName = copyRecord.find("input[name$='.operateRiskLevelName']").val();
	if(operateRiskLevelCode){
		var selectOption = add_content.find("select[name$='.operateRiskLevelCode']").find("option[value='"+operateRiskLevelCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.operateRiskLevelCode']").append("<option selected='selected' value='"+operateRiskLevelCode+"'>"+operateRiskLevelName+"</option>");
		}
	}
	add_content.find("input[name$='.operateRiskLevelName']").val(operateRiskLevelName);
	
	var surgicalSiteCategoryCode = copyRecord.find("select[name$='.surgicalSiteCategoryCode']").val();
	var surgicalSiteCategoryName = copyRecord.find("input[name$='.surgicalSiteCategoryName']").val();
	if(surgicalSiteCategoryCode){
		var selectOption = add_content.find("select[name$='.surgicalSiteCategoryCode']").find("option[value='"+surgicalSiteCategoryCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.surgicalSiteCategoryCode']").append("<option selected='selected' value='"+surgicalSiteCategoryCode+"'>"+surgicalSiteCategoryName+"</option>");
		}
	}
	add_content.find("input[name$='.surgicalSiteCategoryName']").val(surgicalSiteCategoryName);
	
	var surgicalSiteInfectionCode = copyRecord.find("select[name$='.surgicalSiteInfectionCode']").val();
	var surgicalSiteInfectionName = copyRecord.find("input[name$='.surgicalSiteInfectionName']").val();
	if(surgicalSiteInfectionCode){
		var selectOption = add_content.find("select[name$='.surgicalSiteInfectionCode']").find("option[value='"+surgicalSiteInfectionCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.surgicalSiteInfectionCode']").append("<option selected='selected' value='"+surgicalSiteInfectionCode+"'>"+surgicalSiteInfectionName+"</option>");
		}
	}
	add_content.find("input[name$='.surgicalSiteInfectionName']").val(surgicalSiteInfectionName);
	
	var operatedComplicationCode = copyRecord.find("select[name$='.operatedComplicationCode']").val();
	var operatedComplicationName = copyRecord.find("input[name$='.operatedComplicationName']").val();
	if(operatedComplicationCode){
		var selectOption = add_content.find("select[name$='.operatedComplicationCode']").find("option[value='"+operatedComplicationCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.operatedComplicationCode']").append("<option selected='selected' value='"+operatedComplicationCode+"'>"+operatedComplicationName+"</option>");
		}
	}
	add_content.find("input[name$='.operatedComplicationName']").val(operatedComplicationName);
	$('input:radio[name="sex"]:checked').val()
	var isUnPlanReOperateCode = copyRecord.find("input:radio[name$='.isUnPlanReOperateCode']:checked").val();
	if(isUnPlanReOperateCode){
		add_content.find("input:radio[name$='.isUnPlanReOperateCode'][value='"+isUnPlanReOperateCode+"']").attr("checked",true);
	}
	var isUnPlanReOperateName = copyRecord.find("input[name$='.isUnPlanReOperateName']").val();
	add_content.find("input[name$='.isUnPlanReOperateName']").val(isUnPlanReOperateName);
	var unPlanReOperateReasonCode = copyRecord.find("select[name$='.unPlanReOperateReasonCode']").val();
	var unPlanReOperateReasonName = copyRecord.find("input[name$='.unPlanReOperateReasonName']").val();
	if(unPlanReOperateReasonCode){
		var selectOption = add_content.find("select[name$='.unPlanReOperateReasonCode']").find("option[value='"+unPlanReOperateReasonCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.unPlanReOperateReasonCode']").append("<option selected='selected' value='"+unPlanReOperateReasonCode+"'>"+unPlanReOperateReasonName+"</option>");
		}
	}
	add_content.find("input[name$='.unPlanReOperateReasonName']").val(unPlanReOperateReasonName);
	
	var unPlanReOperateIntervalCode = copyRecord.find("select[name$='.unPlanReOperateIntervalCode']").val();
	var unPlanReOperateIntervalName = copyRecord.find("input[name$='.unPlanReOperateIntervalName']").val();
	if(unPlanReOperateIntervalCode){
		var selectOption = add_content.find("select[name$='.unPlanReOperateIntervalCode']").find("option[value='"+unPlanReOperateIntervalCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.unPlanReOperateIntervalCode']").append("<option selected='selected' value='"+unPlanReOperateIntervalCode+"'>"+unPlanReOperateIntervalName+"</option>");
		}
	}
	add_content.find("input[name$='.unPlanReOperateIntervalName']").val(unPlanReOperateIntervalName);
	
	add_content.find("input[name$='.operateWorkers[0].professionTitleCode']").val(copyRecord.find("input[name$='.operateWorkers[0].professionTitleCode']").val());
	add_content.find("input[name$='.operateWorkers[0].professionTitleName']").val(copyRecord.find("input[name$='.operateWorkers[0].professionTitleName']").val());
	add_content.find("input[name$='.operateWorkers[0].medicalWorkerName']").val(copyRecord.find("input[name$='.operateWorkers[0].medicalWorkerName']").val());
	add_content.find("input[name$='.operateWorkers[0].medicalWorkerCode']").val(copyRecord.find("input[name$='.operateWorkers[0].medicalWorkerCode']").val());
	
	add_content.find("input[name$='.operateWorkers[1].professionTitleCode']").val(copyRecord.find("input[name$='.operateWorkers[1].professionTitleCode']").val());
	add_content.find("input[name$='.operateWorkers[1].professionTitleName']").val(copyRecord.find("input[name$='.operateWorkers[1].professionTitleName']").val());
	add_content.find("input[name$='.operateWorkers[1].medicalWorkerName']").val(copyRecord.find("input[name$='.operateWorkers[1].medicalWorkerName']").val());
	add_content.find("input[name$='.operateWorkers[1].medicalWorkerCode']").val(copyRecord.find("input[name$='.operateWorkers[1].medicalWorkerCode']").val());
	
	add_content.find("input[name$='.operateWorkers[2].professionTitleCode']").val(copyRecord.find("input[name$='.operateWorkers[2].professionTitleCode']").val());
	add_content.find("input[name$='.operateWorkers[2].professionTitleName']").val(copyRecord.find("input[name$='.operateWorkers[2].professionTitleName']").val());
	add_content.find("input[name$='.operateWorkers[2].medicalWorkerName']").val(copyRecord.find("input[name$='.operateWorkers[2].medicalWorkerName']").val());
	add_content.find("input[name$='.operateWorkers[2].medicalWorkerCode']").val(copyRecord.find("input[name$='.operateWorkers[2].medicalWorkerCode']").val());
	
	add_content.find("input[name$='.operateWorkers[3].professionTitleCode']").val(copyRecord.find("input[name$='.operateWorkers[3].professionTitleCode']").val());
	add_content.find("input[name$='.operateWorkers[3].professionTitleName']").val(copyRecord.find("input[name$='.operateWorkers[3].professionTitleName']").val());
	add_content.find("input[name$='.operateWorkers[3].medicalWorkerName']").val(copyRecord.find("input[name$='.operateWorkers[3].medicalWorkerName']").val());
	add_content.find("input[name$='.operateWorkers[3].medicalWorkerCode']").val(copyRecord.find("input[name$='.operateWorkers[3].medicalWorkerCode']").val());
	
	add_content.find("input[name$='.operateWorkers[4].medicalWorkerName']").val(copyRecord.find("input[name$='.operateWorkers[4].medicalWorkerName']").val());
	add_content.find("input[name$='.operateWorkers[4].medicalWorkerCode']").val(copyRecord.find("input[name$='.operateWorkers[4].medicalWorkerCode']").val());
	
	add_content.find("input[name$='.operateWorkers[5].medicalWorkerName']").val(copyRecord.find("input[name$='.operateWorkers[5].medicalWorkerName']").val());
	add_content.find("input[name$='.operateWorkers[5].medicalWorkerCode']").val(copyRecord.find("input[name$='.operateWorkers[5].medicalWorkerCode']").val());
	
	add_content.find("input[name$='.operateWorkers[6].medicalWorkerName']").val(copyRecord.find("input[name$='.operateWorkers[6].medicalWorkerName']").val());
	add_content.find("input[name$='.operateWorkers[6].medicalWorkerCode']").val(copyRecord.find("input[name$='.operateWorkers[6].medicalWorkerCode']").val());
	
	add_content.find("input[name$='.operateWorkers[7].medicalWorkerName']").val(copyRecord.find("input[name$='.operateWorkers[7].medicalWorkerName']").val());
	add_content.find("input[name$='.operateWorkers[7].medicalWorkerCode']").val(copyRecord.find("input[name$='.operateWorkers[7].medicalWorkerCode']").val());
	
	add_content.find("input[name$='.operateWorkers[8].medicalWorkerName']").val(copyRecord.find("input[name$='.operateWorkers[8].medicalWorkerName']").val());
	add_content.find("input[name$='.operateWorkers[8].medicalWorkerCode']").val(copyRecord.find("input[name$='.operateWorkers[8].medicalWorkerCode']").val());
	
}
function addOperateRecord(){

	var basePath = $("#basePath").val();
	var operationRecordCountOjb = $("#operationCount");
	var count = parseInt(operationRecordCountOjb.val());
	
    var addli=$("#template_operate_ui li:eq(0)").clone();
    addli.text("记录"+(count+1));
    addli.attr("data-index",count);
    $("#operate_record_ul").append(addli);
    addli.addClass("selected").siblings().removeClass("selected");
    addli.click(function(){
    	$(this).addClass("selected").siblings().removeClass("selected");
        $("#operation_record"+$(this).attr("data-index")).show().siblings().hide();
    });
    var add_content=$("#templateOperateRecord").clone();
    add_content.attr("id","operation_record"+count);
    
    $.each(add_content.find("input[name^='operateRecords[0].']"), function(i,item) {    
    	var inputName = $(item).attr("name");
    	var changeName = inputName.replace("operateRecords[0].","operateRecords["+count+"].");
        $(item).attr("name",changeName);
    });
    
    $.each(add_content.find("select[name^='operateRecords[0].']"), function(i,item) {    
    	var selectName = $(item).attr("name");
    	var changeName = selectName.replace("operateRecords[0].","operateRecords["+count+"].");
        $(item).attr("name",changeName);
        $(item).val("");
    });
    
    $.each(add_content.find("select[name$='.incisionLevelCode'],[name$='.cicatrizeTypeCode'],[name$='.opsLevelCode'],[name$='.operatMarkCode'],[name$='.operateRiskLevelCode']" +
    		",[name$='.anaesthesiaLevelCode'],[name$='.anaesthesiaTypeCode'],[name$='.patientSourceCode'],[name$='.unPlanReOperateReasonCode']" +
    		",[name$='.surgicalSiteInfectionCode'],[name$='.surgicalSiteCategoryCode'],[name$='.unPlanReOperateIntervalCode']" +
    		",[name$='.anaesthesiaUnintendedCode'],[name$='.operatedComplicationCode']"), function(i,item) {    
    	$(this).change(function(){
	   		var eventObj = $(this);
	   		var nameObjName = eventObj.attr("name").replace("Code", "Name");
	   		
	   		if(eventObj.val()!=""){
	   			var name=eventObj.find("option:selected").text();
	   			eventObj.next("input[name='"+nameObjName+"']").val(name);
	   		}else{
	   			eventObj.next("input[name='"+nameObjName+"']").val("");
	   		}
	   });
    });
    add_content.find("input[name$='.isUnPlanReOperateCode']").each(function(){
		$(this).click(function(){
			 $(this).nextAll("input[name='"+$(this).attr("name").replace("Code", "Name")+"']").val($(this).attr("title"));
		 });
		$(this).dblclick(function(){
			$(this).removeAttr("checked");
			
			var title = $(this).parent().find('input:radio[name$=".isUnPlanReOperateCode"]:checked').attr("title");
			$(this).nextAll("input[name='"+$(this).attr("name").replace("Code", "Name")+"']").val(title);
		});
	});
    $.each(add_content.find("#operateBodyPart"), function(i,item) {    
    	$(item).attr("id",$(item).attr("id")+count);
    	
    	$(item).bind('DOMNodeInserted', function(e) {
    		add_content.find("input[name$='.operateBodyPartCodes']").val($(this).attr("data-id"));
    		add_content.find("input[name$='.operateBodyPartNames']").val($(this).text());
    	}).hsCheckData({
            isShowCheckBox: true, //默认为false
            //minCheck: 3,//默认为0，不限最少选择个数
            //maxCheck: 6,//默认为0，不限最多选择个数
            data: bodyPartData
    	});
    });
    
    $.each(add_content.find("input[name$='.operateDescShow']"), function(i,item) {    
    	$(this).autocomplete({
    		source: function( request, response ) {
    			var eventObj = $(this.element);
    			var codeObjName = eventObj.attr("name").replace("DescShow", "Code");
				eventObj.nextAll("input[name='"+codeObjName+"']").val("");
				
				var nameObjName = eventObj.attr("name").replace("DescShow", "Name");
				eventObj.nextAll("input[name='"+nameObjName+"']").val("");
				
    			$.ajax({
    				url: basePath + "base_info/ajax_operate_by_query_name",
    				dataType: "json",
    				data:{
    					queryName: request.term
    				},
    				success: function( data ) {
						if(data.length > 0){
							response( $.map( data, function( item ) {
								return {
		    						label:item.uniq_code+'['+item.label+']',
									uniq_code:item.uniq_code,
									uniq_name:item.label,
									level_code:item.level_code,
									level_name:item.level_name,
									mark_code:item.mark_code,
									mark_name:item.mark_name
		    					}
							}));
						}else{
							response([[]]);
						}
	    			}
	    		});
    		},
    		minLength: 2,
    		select: function( event, ui ) {
				var eventObj = $(this);
				var item = ui.item;
				var codeObjName = eventObj.attr("name").replace("DescShow", "Code");
				eventObj.nextAll("input[name='"+codeObjName+"']").val(item.uniq_code);
				
				var nameObjName = eventObj.attr("name").replace("DescShow", "Name");
				eventObj.nextAll("input[name='"+nameObjName+"']").val(item.uniq_name);
				if(item.level_code){
					var selectedIndex = eventObj.parent().parent().parent().find("select[name$='.opsLevelCode'] option[value='"+item.level_code+"']").first().index();
					if(selectedIndex > -1){
						eventObj.parent().parent().parent().find("select[name$='.opsLevelCode']").get(0).selectedIndex = selectedIndex;
						
					}
					
				}
				if(item.level_name){
					eventObj.parent().parent().parent().find("input[name$='.opsLevelName']").val(item.level_name);
					
				}
				
				if(item.mark_code){
					var selectedIndex = eventObj.parent().parent().parent().find("select[name$='.operatMarkCode'] option[value='"+item.mark_code+"']").first().index();
					if(selectedIndex > -1){
						eventObj.parent().parent().parent().find("select[name$='.operatMarkCode']").get(0).selectedIndex = selectedIndex;
						
					}
					
				}
				if(item.mark_name){
					eventObj.parent().parent().parent().find("input[name$='.operatMarkName']").val(item.mark_name);
					
				}
			},search: function( event, ui ) {
				var eventObj = $(this);
				var codeObjName = eventObj.attr("name").replace("DescShow", "Code");
				eventObj.nextAll("input[name='"+codeObjName+"']").val("");
				
				var nameObjName = eventObj.attr("name").replace("DescShow", "Name");
				eventObj.nextAll("input[name='"+nameObjName+"']").val("");
				eventObj.parent().parent().parent().find("select[name$='.opsLevelCode']").get(0).selectedIndex = 0;
				eventObj.parent().parent().parent().find("input[name$='.opsLevelName']").val(null);
				eventObj.parent().parent().parent().find("select[name$='.operatMarkCode']").get(0).selectedIndex = 0;
				eventObj.parent().parent().parent().find("input[name$='.operatMarkName']").val(null);
				
			},change: function( event, ui ) {
				if(ui.item == null){
					var eventObj = $(this);
					var codeObjName = eventObj.attr("name").replace("DescShow", "Code");
					eventObj.nextAll("input[name='"+codeObjName+"']").val(null);
					var nameObjName = eventObj.attr("name").replace("DescShow", "Name");
					eventObj.nextAll("input[name='"+nameObjName+"']").val(null);
					eventObj.parent().parent().parent().find("select[name$='.opsLevelCode']").get(0).selectedIndex = 0;
					eventObj.parent().parent().parent().find("input[name$='.opsLevelName']").val(null);
					eventObj.parent().parent().parent().find("select[name$='.operatMarkCode']").get(0).selectedIndex = 0;
					eventObj.parent().parent().parent().find("input[name$='.operatMarkName']").val(null);
				}
		    },
			close: function( event, ui ) {
				var eventObj = $(this);
				var codeObjName = eventObj.attr("name").replace("DescShow", "Code");
				var codeValue = eventObj.nextAll("input[name='"+codeObjName+"']").val();
				if(!codeValue){
					eventObj.val(null);
				}
		    }
    	});
    });
    
    $.each(add_content.find("input[name$='.operateExtraShow']"), function(i,item) {    
    	$(this).autocomplete({
    		source: function( request, response ) {
    			var eventObj = $(this.element);
    			var codeObjName = eventObj.attr("name").replace("Show", "Code");
				eventObj.nextAll("input[name='"+codeObjName+"']").val("");
				
				var nameObjName = eventObj.attr("name").replace("Show", "Name");
				eventObj.nextAll("input[name='"+nameObjName+"']").val("");
				
    			$.ajax({
    				url: basePath + "base_info/ajax_operate_by_query_name",
    				dataType: "json",
    				data:{
    					queryName: request.term
    				},
    				success: function( data ) {
						if(data.length > 0){
							response( $.map( data, function( item ) {
								return {
									label:item.uniq_code+'['+item.label+']',
									uniq_code:item.uniq_code,
									uniq_name:item.label
								}
							}));
						}else{
							response([[]]);
						}
					}
    		});
    		},
    		minLength: 2,
    		select: function( event, ui ) {
				var eventObj = $(this);
				var item = ui.item;
				var codeObjName = eventObj.attr("name").replace("Show", "Code");
				eventObj.nextAll("input[name='"+codeObjName+"']").val(item.uniq_code);
				
				var nameObjName = eventObj.attr("name").replace("Show", "Name");
				eventObj.nextAll("input[name='"+nameObjName+"']").val(item.uniq_name);
			},search: function( event, ui ) {
				var eventObj = $(this);
				var codeObjName = eventObj.attr("name").replace("Show", "Code");
				eventObj.nextAll("input[name='"+codeObjName+"']").val("");
				
				var nameObjName = eventObj.attr("name").replace("Show", "Name");
				eventObj.nextAll("input[name='"+nameObjName+"']").val("");
				
			},change: function( event, ui ) {
				if(ui.item == null){
					var eventObj = $(this);
					var codeObjName = eventObj.attr("name").replace("Show", "Code");
					eventObj.nextAll("input[name='"+codeObjName+"']").val(null);
					var nameObjName = eventObj.attr("name").replace("Show", "Name");
					eventObj.nextAll("input[name='"+nameObjName+"']").val(null);
				}
		    },
			close: function( event, ui ) {
				var eventObj = $(this);
				var codeObjName = eventObj.attr("name").replace("Show", "Code");
				var codeValue = eventObj.nextAll("input[name='"+codeObjName+"']").val();
				if(!codeValue){
					eventObj.val(null);
				}
		    }
    	});
    });
    
    $.each(add_content.find("input[name$='.medicalWorkerName']"), function(i,item) {
    	$(this).autocomplete({
    		source: function( request, response ) {
    			var eventObj = $(this.element);
    			var basePath = $("#basePath").val();
    			var objCode = eventObj.attr("name").replace("Name", "Code");
    			eventObj.next("input[name='"+objCode+"']").val("");
    			$.ajax({
    				url: basePath + "base_info/ajax_medical_worker_by_query_name",
    				dataType: "json",
    				data:{
    					queryName: request.term
    				},
    				success: function( data ) {

						if(data.length > 0){
							response( $.map( data, function( item ) {
								return {
									label:item.label,
		    						uniq_code:item.uniq_code
								}
							}));
						}else{
							response([[]]);
						}
	    			}
	    		});
    		},
    		minLength: 1,
    		select: function( event, ui ) {
    			var eventObj = $(this);
    			var item = ui.item;
    			var objCode = eventObj.attr("name").replace("Name", "Code");
    			eventObj.next("input[name='"+objCode+"']").val(item.uniq_code);
    		},search: function( event, ui ) {
    			var eventObj = $(this);
    			var objCode = eventObj.attr("name").replace("Name", "Code");
    			eventObj.next("input[name='"+objCode+"']").val("");
    		}/*,change: function( event, ui ) {
				if(ui.item == null){
					var eventObj = $(this);
					eventObj.val(null);
					var codeObjName = eventObj.attr("name").replace("Name", "Code");
					eventObj.nextAll("input[name='"+codeObjName+"']").val(null);
				}
		    }*//*,
			close: function( event, ui ) {
				var eventObj = $(this);
				var codeObjName = eventObj.attr("name").replace("Name", "Code");
				var codeValue = eventObj.nextAll("input[name='"+codeObjName+"']").val();
				if(!codeValue){
					eventObj.val(null);
				}
		    }*/
    	});
    });
    
    $("#operation_records").append(add_content);
    add_content.show().siblings().hide();
    operationRecordCountOjb.val(count+1);
    
    var descShowObj = add_content.find("input[name$='.operateDescShow']").first();
    if(descShowObj){
    	descShowObj.rules("add",{required:true,minlength: 5});
    }
    
    var operateStartDateObj = add_content.find("input[name$='.operateStartDate']").first();
    if(operateStartDateObj){
    	operateStartDateObj.rules("add",{required:true});
    }
    
    var operateEndDateObj = add_content.find("input[name$='.operateEndDate']").first();
    if(operateEndDateObj){
    	operateEndDateObj.rules("add",{required:true});
    }
    
    var anesthesiaStartTimeObj = add_content.find("input[name$='.anesthesiaStartTime']").first();
//    if(anesthesiaStartTimeObj){
//    	anesthesiaStartTimeObj.rules("add",{required:true});
//    }
    var anesthesiaEndTimeObj = add_content.find("input[name$='.anesthesiaEndTime']").first();
//    if(anesthesiaEndTimeObj){
//    	anesthesiaEndTimeObj.rules("add",{required:true});
//    }
    
    var sortIndexObj = add_content.find("input[name$='.operateSortIndex']").first();
    if(sortIndexObj){
    	sortIndexObj.rules("add",{digits:true,range:[1,1000]});
    }
    
    return add_content;
}


function addOperateRecordByRecord(operateRecord){
	var add_content = addOperateRecord();
	
	
	add_content.find("input[name$='.operateStartDate']").val(operateRecord.operateStartDate);
	add_content.find("input[name$='.operateEndDate']").val(operateRecord.operateEndDate);
	add_content.find("input[name$='.anesthesiaStartTime']").val(operateRecord.anesthesiaStartTime);
	add_content.find("input[name$='.anesthesiaEndTime']").val(operateRecord.anesthesiaEndTime);
	var operateOriginalShow = null;
	if(operateRecord.operateOriginalCode){
		operateOriginalShow = operateRecord.operateOriginalCode +"["+operateRecord.operateOriginalDesc+"]";
	}else{
		operateOriginalShow = operateRecord.operateOriginalDesc
	}
	add_content.find("span[class='operateOriginalShow']").html(operateOriginalShow);
	add_content.find("input[name$='.operateOriginalDesc']").val(operateRecord.operateOriginalDesc);
	add_content.find("input[name$='.operateOriginalCode']").val(operateRecord.operateOriginalCode);
	
	
	
	if(operateRecord.operateCode){
		add_content.find("input[name$='.operateDescShow']")
		.val(operateRecord.operateCode+'['+operateRecord.operateName+']');
	}
	add_content.find("input[name$='.operateCode']").val(operateRecord.operateCode);
	add_content.find("input[name$='.operateName']").val(operateRecord.operateName);
	

	for(var extraIndex in operateRecord.operateExtraRecords){
		var extraRecord = operateRecord.operateExtraRecords[extraIndex];
		var operateExtraShow = null;
		if(extraRecord.operateExtraCode){
			operateExtraShow = extraRecord.operateExtraCode +"["+extraRecord.operateExtraName+"]";
		}else{
			operateExtraShow = extraRecord.operateExtraName
		}
		add_content.find("input[name$='.operateExtraRecords["+extraIndex+"].operateExtraShow']").val(operateExtraShow);
		add_content.find("input[name$='.operateExtraRecords["+extraIndex+"].operateExtraCode']").val(extraRecord.operateExtraCode);
		add_content.find("input[name$='.operateExtraRecords["+extraIndex+"].operateExtraName']").val(extraRecord.operateExtraName);
	}
	
	
	add_content.find("input[name$='.operateDurationTime']").val(operateRecord.operateDurationTime);
	if(operateRecord.incisionLevelCode){
		
		var selectOption = add_content.find("select[name$='.incisionLevelCode']").find("option[value='"+operateRecord.incisionLevelCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.incisionLevelCode']").append("<option selected='selected' value='"+operateRecord.incisionLevelCode+"'>"+operateRecord.incisionLevelName+"</option>");
		}
	}
	add_content.find("input[name$='.incisionLevelName']").val(operateRecord.incisionLevelName);
	
	if(operateRecord.cicatrizeTypeCode){
		
		var selectOption = add_content.find("select[name$='.cicatrizeTypeCode']").find("option[value='"+operateRecord.cicatrizeTypeCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.cicatrizeTypeCode']").append("<option selected='selected' value='"+operateRecord.cicatrizeTypeCode+"'>"+operateRecord.cicatrizeTypeName+"</option>");
		}
	}
	add_content.find("input[name$='.cicatrizeTypeName']").val(operateRecord.cicatrizeTypeName);
	
	if(operateRecord.opsLevelCode){
		
		var selectOption = add_content.find("select[name$='.opsLevelCode']").find("option[value='"+operateRecord.opsLevelCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.opsLevelCode']").append("<option selected='selected' value='"+operateRecord.opsLevelCode+"'>"+operateRecord.opsLevelName+"</option>");
		}
	}
	add_content.find("input[name$='.opsLevelName']").val(operateRecord.opsLevelName);
	
	if(operateRecord.operatMarkCode){
		
		var selectOption = add_content.find("select[name$='.operatMarkCode']").find("option[value='"+operateRecord.operatMarkCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.operatMarkCode']").append("<option selected='selected' value='"+operateRecord.operatMarkCode+"'>"+operateRecord.operatMarkName+"</option>");
		}
	}
	add_content.find("input[name$='.operatMarkName']").val(operateRecord.operatMarkName);
	
	
	if(operateRecord.operateRiskLevelCode){
		
		var selectOption = add_content.find("select[name$='.operateRiskLevelCode']").find("option[value='"+operateRecord.operateRiskLevelCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.operateRiskLevelCode']").append("<option selected='selected' value='"+operateRecord.operateRiskLevelCode+"'>"+operateRecord.operateRiskLevelName+"</option>");
		}
	}
	add_content.find("input[name$='.operateRiskLevelName']").val(operateRecord.operateRiskLevelName);
	
	if(operateRecord.anaesthesiaLevelCode){
		
		var selectOption = add_content.find("select[name$='.anaesthesiaLevelCode']").find("option[value='"+operateRecord.anaesthesiaLevelCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.anaesthesiaLevelCode']").append("<option selected='selected' value='"+operateRecord.anaesthesiaLevelCode+"'>"+operateRecord.anaesthesiaLevelName+"</option>");
		}
	}
	add_content.find("input[name$='.anaesthesiaLevelName']").val(operateRecord.anaesthesiaLevelName);
	
	if(operateRecord.anaesthesiaTypeCode){
		
		var selectOption = add_content.find("select[name$='.anaesthesiaTypeCode']").find("option[value='"+operateRecord.anaesthesiaTypeCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.anaesthesiaTypeCode']").append("<option selected='selected' value='"+operateRecord.anaesthesiaTypeCode+"'>"+operateRecord.anaesthesiaTypeName+"</option>");
		}
	}
	add_content.find("input[name$='.anaesthesiaTypeName']").val(operateRecord.anaesthesiaTypeName);
	
	if(operateRecord.anaesthesiaUnintendedCode){
		
		var selectOption = add_content.find("select[name$='.anaesthesiaUnintendedCode']").find("option[value='"+operateRecord.anaesthesiaUnintendedCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.anaesthesiaUnintendedCode']").append("<option selected='selected' value='"+operateRecord.anaesthesiaUnintendedCode+"'>"+operateRecord.anaesthesiaUnintendedName+"</option>");
		}
	}
	add_content.find("input[name$='.anaesthesiaUnintendedName']").val(operateRecord.anaesthesiaUnintendedName);
	
	if(operateRecord.operatedComplicationCode){
		
		var selectOption = add_content.find("select[name$='.operatedComplicationCode']").find("option[value='"+operateRecord.operatedComplicationCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.operatedComplicationCode']").append("<option selected='selected' value='"+operateRecord.operatedComplicationCode+"'>"+operateRecord.operatedComplicationName+"</option>");
		}
	}
	add_content.find("input[name$='.operatedComplicationName']").val(operateRecord.operatedComplicationName);
	
	
	
	
	if(operateRecord.isUnPlanReOperateCode){
		add_content.find("input[name$='.isUnPlanReOperateCode'][value='"+operateRecord.isUnPlanReOperateCode+"']").attr("checked",true);
	}
	add_content.find("input[name$='.isUnPlanReOperateName']").val(operateRecord.isUnPlanReOperateName);
	
	if(operateRecord.unPlanReOperateReasonCode){
		
		var selectOption = add_content.find("select[name$='.unPlanReOperateReasonCode']").find("option[value='"+operateRecord.unPlanReOperateReasonCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.unPlanReOperateReasonCode']").append("<option selected='selected' value='"+operateRecord.unPlanReOperateReasonCode+"'>"+operateRecord.unPlanReOperateReasonName+"</option>");
		}
	}
	add_content.find("input[name$='.unPlanReOperateReasonName']").val(operateRecord.unPlanReOperateReasonName);
	
	if(operateRecord.surgicalSiteInfectionCode){
		
		var selectOption = add_content.find("select[name$='.surgicalSiteInfectionCode']").find("option[value='"+operateRecord.surgicalSiteInfectionCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.surgicalSiteInfectionCode']").append("<option selected='selected' value='"+operateRecord.surgicalSiteInfectionCode+"'>"+operateRecord.surgicalSiteInfectionName+"</option>");
		}
	}
	add_content.find("input[name$='.surgicalSiteInfectionName']").val(operateRecord.surgicalSiteInfectionName);
	
	
	if(operateRecord.surgicalSiteCategoryCode){
		
		var selectOption = add_content.find("select[name$='.surgicalSiteCategoryCode']").find("option[value='"+operateRecord.surgicalSiteCategoryCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.surgicalSiteCategoryCode']").append("<option selected='selected' value='"+operateRecord.surgicalSiteCategoryCode+"'>"+operateRecord.surgicalSiteCategoryName+"</option>");
		}
	}
	add_content.find("input[name$='.surgicalSiteCategoryName']").val(operateRecord.surgicalSiteCategoryName);
	
	if(operateRecord.unPlanReOperateIntervalCode){
		
		var selectOption = add_content.find("select[name$='.unPlanReOperateIntervalCode']").find("option[value='"+operateRecord.unPlanReOperateIntervalCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.unPlanReOperateIntervalCode']").append("<option selected='selected' value='"+operateRecord.unPlanReOperateIntervalCode+"'>"+operateRecord.unPlanReOperateIntervalName+"</option>");
		}
	}
	add_content.find("input[name$='.unPlanReOperateIntervalName']").val(operateRecord.unPlanReOperateIntervalName);
	
	
	if(operateRecord.patientSourceCode){
		
		var selectOption = add_content.find("select[name$='.patientSourceCode']").find("option[value='"+operateRecord.patientSourceCode+"']")
		if(selectOption.length > 0){
			selectOption.attr("selected",true);
		}else{
			add_content.find("select[name$='.patientSourceCode']").append("<option selected='selected' value='"+operateRecord.patientSourceCode+"'>"+operateRecord.patientSourceName+"</option>");
		}
	}
	add_content.find("input[name$='.patientSourceName']").val(operateRecord.patientSourceName);
	if(operateRecord.operateBodyPartCodes){
		add_content.find("div[id^='operateBodyPart']").attr("data-id",operateRecord.operateBodyPartCodes).text(operateRecord.operateBodyPartNames);
		
	}
	add_content.find("input[name$='.operateBodyPartCodes']").val(operateRecord.operateBodyPartCodes);
	add_content.find("input[name$='.operateBodyPartNames']").val(operateRecord.operateBodyPartNames);
	var operateWorkers = operateRecord.operateWorkers
	for(var index in operateWorkers){
		var operateWorker = operateWorkers[index];
		var professionTitleNameObj = add_content.find("input[value='"+operateWorker.professionTitleName+"']");
		professionTitleNameObj.nextAll("input[name$='medicalWorkerName']").val(operateWorker.medicalWorkerName);
		professionTitleNameObj.nextAll("input[name$='medicalWorkerCode']").val(operateWorker.medicalWorkerCode);
		
    } 
	add_content.find("input[name$='.operateSortIndex']").val(operateRecord.operateSortIndex);
	add_content.find("input[name$='.operatingLevel']").val(operateRecord.operatingLevel);

	
}
function deleteOperateRecord(){
    /*选项卡删除最后一项*/
	var delete_option = $("#operate_record_ul li[class='selected']");
	var delete_index = delete_option.attr("data-index");
	var operatingLevels = $("#operation_record"+delete_index+" input[name$='.operatingLevel']");
	if(operatingLevels.length > 0){
		var operatingLevel = operatingLevels.first();
		if("1" == operatingLevel.val()){
			alert("此手术不允许删除！！！");
		}else{
			delete_option.remove();
			/*内容删除最后一项*/
		    $("#operation_record"+delete_index).remove();
		    /*$("#operate_record_ul li:last").addClass("selected").siblings().removeClass("selected");
		    
		    $("#operation_records div:last").show().siblings().hide();*/
		    $("#operate_record_ul li:last").click();
		}
		
		
	}else{
		
		
		delete_option.remove();
		/*内容删除最后一项*/
	    $("#operation_record"+delete_index).remove();
	    $("#operate_record_ul li:last").click();
	    /*$("#operate_record_ul li:last").addClass("selected").siblings().removeClass("selected");
	    
	    $("#operation_records div:last").show().siblings().hide();*/
	}
	
}